<include file="Public/header" xmlns="http://www.w3.org/1999/html"/>
<include file="Public/menu" />
<link rel="stylesheet" href="/Public/admin/adminlte/bootstrap/css/bootstrap-switch.min.css">

<style>
    .form-inline .input-group {
        display: inline-table;
        vertical-align: middle;
    }


</style>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            统计
            <small>商品销售统计</small>
        </h1>
        <ol class="breadcrumb">
            <li><i class="fa fa-dashboard"></i> 首页</li>
            <li><a><i class="fa fa-dashboard"></i> 统计</a></li>
            <li class="active">商品统计</li>
        </ol>
    </section>



    <!-- 内容 -->
    <section class="content"><div class="row"><div class="col-md-12">

        <div class="nav-tabs-custom" style=" margin-bottom: 0; padding-bottom: 15px;">
            <ul class="nav nav-tabs">
                <li <if condition="$view eq 0">class="active"</if> ><a href="/Admin/StoreGoodsSales/goodsSale/view/0.html">商品销售统计</a></li>
                <li <if condition="$view eq 1">class="active"</if>><a href="/Admin/StoreItemSell/index/view/1.html">商品销售分类</a></li>
                <li <if condition="$view eq 2">class="active"</if> ><a href="/Admin/StoreItemSell/index/view/2.html">商品销售排行Top100</a></li>
                <li class="pull-right header"></li>
            </ul>
            </div>
        <div style="background-color: #fff;">

        <div class="form-inline">



            <form  id="search_form" name="search_form" action=""  method="get" >
                <div class="box-header">
                    <h3 class="box-title">日期选择</h3>

                    <div class="input-group input-group-sm isOrderChangeDate" >
                        <div class="input-group input-group-sm date form_datetime">
                            <input id="start_time" class="form-control" type="text" name="start_time" value="{$_GET['start_time']|default='开始时间'}" readonly>
                        </div>
                        <div class="btn-group">--</div>
                        <div class="input-group input-group-sm date">
                            <input id="end_time" class="form-control" type="text" name="end_time" value="{$_GET['end_time']|default='结束时间'}" readonly>
                        </div>
                    </div>

                    <div class="input-group input-group-sm">
                        <div class="input-group-btn">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                        </div>
                        <div class="btn-group pull-right" style="margin: 0 10px">
                            <a href="javascript:exportexcel()" target="_blank" class="btn btn-sm btn-warning" style="margin-right: 5px;"><i class="fa fa-download"></i>&nbsp;&nbsp;导出EXCEL</a>
                        </div>
                    </div>


                </div>

            </form>

            <form action="/Admin/StoreGoodsSales/goodsSalesExport" method="post" id="exportexcel_form">
                <input type="hidden" id="hidden-start-time"  name="hidden-start-time">
                <input type="hidden" id="hidden-end-time" name="hidden-end-time">
            </form>


            </div>
        <br>
            <!-- /.box-header -->
            <div class="box-body table-responsive">
                <table class="table table-hover table-bordered text-center">
                    <tbody>
                    <tr>
                        <th>日期</th>
                        <th>条码</th>
                        <th>商品编码</th>
                        <th>商品名</th>
                        <th>销售商品数量</th>
                        <th>销售金额/元</th>
                    </tr>

                    <?php foreach($list as $k => $v){?>
                    <?php foreach($v as $key => $item) {?>
                    <tr>
                        <?php if($key == 0) {?>
                        <td rowspan="<?php echo count($v)?>"><?php echo $k;?></td>
                        <?php }?>
                        <td><?php echo $item['barcode'];?></td>
                        <td><?php echo $item['bn'];?></td>
                        <td style="text-align: left"><?php echo $item['goods_name'];?></td>
                        <td><?php echo $item['sum_num'];?></td>
                        <td><?php echo $item['sum_total'];?></td>
                    </tr>
                    <?php }?>
                    <?php }?>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">
                {$page}
            </div>

            <!-- /.box-body -->
        </div></div>
    </div>
    </section>
</div>

<script src="/Public/layer/layer.js"></script>
<script src="/Public/admin/laydate/laydate.js"></script>
<script>
    layerTime();
    function layerTime(){
        var start = {
            elem: "#start_time",
            format: 'YYYY-MM-DD',
            min: '1970-01-01 00:00:00', //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: false,
            istoday: false,
            choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: "#end_time",
            format: 'YYYY-MM-DD',
            min: '1970-01-01 00:00:00',
            max: '2099-06-16 23:59:59',
            istime: false,
            istoday: false,
            choose: function(datas){
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
    }
    
    function exportexcel() {
       $star_time = $('#start_time').val();
       $end_time = $('#end_time').val();
       $('#hidden-start-time').val($star_time);
       $('#hidden-end-time').val($end_time);
       $('#exportexcel_form').submit();
    }


</script>

<!-- 底部 -->
<include file="Public/common_footer" />